(function(vc){
    vc.extends({
        propTypes: {
           emitChooseLabel:vc.propTypes.string,
           emitLoadData:vc.propTypes.string
        },
        data:{
            chooseLabelInfo:{
                labels:[],
                _currentLabelName:'',
            }
        },
        _initMethod:function(){
        },
        _initEvent:function(){
            vc.on('chooseLabel','openChooseLabelModel',function(_param){
                $('#chooseLabelModel').modal('show');
                $that._refreshChooseLabelInfo();
                $that._loadAllLabelInfo(1,10,'');
            });
        },
        methods:{
            _loadAllLabelInfo:function(_page,_row,_name){
                var param = {
                    params:{
                        page:_page,
                        row:_row,
                        communityId:vc.getCurrentCommunity().communityId,
                        name:_name
                    }
                };

                //发送get请求
               vc.http.apiGet('label.listLabels',
                             param,
                             function(json){
                                var _labelInfo = JSON.parse(json);
                                $that.chooseLabelInfo.labels = _labelInfo.labels;
                             },function(){
                                console.log('请求失败处理');
                             }
                           );
            },
            chooseLabel:function(_label){
                if(_label.hasOwnProperty('name')){
                     _label.labelName = _label.name;
                }
                vc.emit($props.emitChooseLabel,'chooseLabel',_label);
                vc.emit($props.emitLoadData,'listLabelData',{
                    labelId:_label.labelId
                });
                $('#chooseLabelModel').modal('hide');
            },
            queryLabels:function(){
                $that._loadAllLabelInfo(1,10,$that.chooseLabelInfo._currentLabelName);
            },
            _refreshChooseLabelInfo:function(){
                $that.chooseLabelInfo._currentLabelName = "";
            }
        }

    });
})(window.vc);
